<template>
  <div class="bj-racer" v-if="!getIsPhone">
    <select-number-public 
      :options="options"
      :currentLottery="getLotteryType.lotteryName"
      :winningInfo="winningInfo"
      :winningNumbers="winningNumbers"
      @mutate="handleMutate"
      >
      <template v-slot:winninginfo>
        <winning-numbers :winningNumbers="winningNumbers">
          <winning-info-sc :winningNumbers="winningNumbers"></winning-info-sc>
        </winning-numbers>
      </template>
      <transition name="fade" mode="out-in">
        <component :is="getCurrentComponent"></component>
      </transition>
    </select-number-public>
  </div>
  <div class="bj-racer-phone" v-else>
    <div class="fixed-top">
      <winning-numbers :winningNumbers="winningNumbers">
        <div class="numbers">
          <span class="border-right" v-for="(number, index) in winningNumbers.previous.numbers.split(',')" :key="index">{{number}}</span>
        </div>
      </winning-numbers>
      <sub-dropdown-phone @click="updateSwitchIndex" :activeSwitchIndex="activeSwitchIndex"></sub-dropdown-phone>
    </div>
    <transition name="fade" mode="out-in">
      <component :is="getCurrentComponent" :activeSwitchIndexPhone="activeSwitchIndex"></component>
    </transition>
    <side-slider-phone :options="options" @click="handleMutate"></side-slider-phone>
  </div>
</template>

<script>
import SelectNumberPublic from '@/components/select-number-public/select-number-public'
import WinningNumbers from '@/components/winning-numbers/winning-numbers'
import WinningInfoSc from '@/components/winning-info/winning-info-sc'
import shiweizhixuan from '@/components/lottery-type/saiche/shiweizhixuan'
import qianyizhixuan from '@/components/lottery-type/saiche/qianyizhixuan'
import guanyahezhi from '@/components/lottery-type/saiche/guanyahezhi'
import guanyazuhe from '@/components/lottery-type/saiche/guanyazuhe'
import tema from '@/components/lottery-type/saiche/tema'
import longhu from '@/components/lottery-type/saiche/longhu'
import liangmian from '@/components/lottery-type/saiche/liangmian'
import SideSliderPhone from '@/components/base/phone/side-slider-phone/side-slider-phone'
import SubDropdownPhone from '@/components/base/phone/sub-dropdown-phone/sub-dropdown-phone'

import { mapGetters, mapMutations } from 'vuex'

export default {
  components: {
    SelectNumberPublic,
    WinningNumbers,
    WinningInfoSc,
    shiweizhixuan,
    qianyizhixuan,
    guanyahezhi,
    guanyazuhe,
    tema,
    longhu,
    liangmian,
    SideSliderPhone,
    SubDropdownPhone
  },
  data() {
    return {
      activeSwitchIndex: 0,
      // 开奖信息
      winningNumbers: {
        id: 'bjsc',
        lotteryName: '北京赛车',
        dateNo: '819048',
        previous: {
          dateNo: '819049',
          numbers: '1,2,3,4,5,6,7,8,9,10',
          context: '13,大,小,单,双,龙,虎,闲',
        },
        closeTime: new Date().getTime() + 1000000,
        drawTime: new Date().getTime() + 10000000
      },
      // 前10期中奖信息
      winningInfo: [
        { 
          id: 1,
          series: 819049,
          numbers: '0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 2,
          series: 819049,
          numbers:'0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 3,
          series: 819049,
          numbers:'0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 4,
          series: 819049,
          numbers: '0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 5,
          series: 819049,
          numbers: '0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 6,
          series: 819049,
          numbers: '0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 7,
          series: 819049,
          numbers: '0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 8,
          series: 819049,
          numbers: '0,1,2,3,4,5,5,7,8,9'
        },
        {
          id: 9,
          series: 819049,
          numbers:'0,1,2,3,4,5,5,7,8,9'
        }
      ],
      // 北京赛车tab数据选项
      options: [
        {
          id: 'c_g_j',
          context: '猜冠军',
          currentComponent: 'qianyizhixuan',
          currentSubTab: '前一直选',
          currentSubId: 'qy_zx',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'qy_zx',
                  context: '前一直选',
                  components: 'qianyizhixuan',
                },
              ]
            }
          ]
        },
        {
          id: 'c_gy_j',
          context: '猜冠亚军',
          currentComponent: '',
          currentSubTab: '冠亚军',
          currentSubId: 'g_y_j',
          sub: [
           {
              cate: '玩法',
              tabnames: [
                 {
                  id: 'g_y_j',
                  context: '冠亚军',
                }
              ]
           }
          ]
        },
        {
          id: 'c_qsm',
          context: '猜前三名',
          currentComponent: '',
          currentSubTab: '前三',
          currentSubId: 'q_s',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'q_s',
                  context: '前三',
                  components: '',
                }
              ]
            }
          ]
        },
        {
          id: 'd_w_d',
          context: '定位胆',
          currentComponent: 'shiweizhixuan',
          currentSubTab: '十位直选',
          currentSubId: 'sw_zx',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'sw_zx',
                  context: '十位直选',
                  components: 'shiweizhixuan',
                }
              ]
            }
          ],
        },
        {
          id: 'xy_wf',
          context: '信用玩法',
          currentComponent: 'liangmian',
          currentSubTab: '两面',
          currentSubId: 'l_m',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'l_m',
                  context: '两面',
                  components: 'liangmian'
                },
                {
                  id: 'l_h',
                  context: '龙虎',
                  components: 'longhu'
                },
                {
                  id: 'tema',
                  context: '特码',
                  components: 'tema'
                },
                {
                  id: 'gy_hz',
                  context: '冠亚和值',
                  components: 'guanyahezhi',
                },
                {
                  id: 'gy_zh',
                  context: '冠亚组合',
                  components: 'guanyazuhe'
                },
              ]
            }
          ]
        }
      ],
    }
  },
  created() {
    this.setLotteryType({lotteryName: this.winningNumbers.lotteryName, id: this.winningNumbers.id})
    this.setCurrentLotteryDateNo(this.winningNumbers.dateNo)
    this.setCurrentSubId(this.options[0].currentSubId)
    this.setCurrentComponent(this.options[0].currentComponent)
    this.setCurrentMainTab({mainTabName: this.options[0].context, id: this.options[0].id })
    this.setCurrentTab({subTabName: this.options[0].currentSubTab, id: this.options[0].currentSubId})
  },
  methods: {
    updateSwitchIndex(index) {
      this.activeSwitchIndex = index
    },
    // 更新选中状态
    handleMutate(options) {
      this.options = options
    },
    ...mapMutations('lottery', {
      setLotteryType: 'SET_LOTTERY_TYPE',
      setCurrentComponent: 'SET_CURRENT_COMPONENT',
      setCurrentMainTab: 'SET_CURRENT_MAIN_TAB',
      setCurrentTab: 'SET_CURRENT_TAB',
      setCurrentLotteryDateNo: 'SET_CURRENT_LOTTERY_DATE_NO',
      setCurrentSubId: 'SET_CURRENT_SUB_ID'
    })
  },
  computed: {
    ...mapGetters('lottery', ['getCurrentComponent','getIsPhone', 'getLotteryType'])
  }
 
}
</script>

<style lang="stylus" scoped>
@import '~@/assets/styles/variables.styl'
  &.fade-enter, &.fade-leave-to 
    opacity 0
  &.fade-leave, &.fade-enter-to 
    opacity 1
  &.fade-enter-active, &.fade-leave-active 
    transition all 0.2s 
  @media screen and (max-width 750px) 
    .bj-racer-phone 
      width 100%
      box-sizing border-box
      padding-top 148px
      .fixed-top 
        position fixed 
        top 48px 
        left 0 
        right 0 
        z-index 9
        background #fff
        .numbers 
          span  
            display inline-block
            width 25px
            height 10px
            line-height 10px
            text-align center
            font-size 16px 
            font-weight 400
            font-family $sub-font-family
            color $color-theme-red 
            font-weight 700
          
</style>